package com.wzy.oa_sys.controller.user;

import com.wzy.oa_sys.model.pojo.user.OaPosition;
import com.wzy.oa_sys.model.request.user.PositionReq;
import com.wzy.oa_sys.model.response.user.PositionResp;
import com.wzy.oa_sys.service.user.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/position")
public class PositionController {

    @Autowired
    private PositionService positionService;


    @GetMapping("/list")
    public List<PositionResp> getPositionList() {
        return positionService.getPositionList();
    }

    @PostMapping("/addOption")
    public void addOption(@RequestBody PositionReq positionReq) {
        System.out.println("添加岗位："+positionReq.toString());
        positionService.addOption(positionReq);
    }

    @DeleteMapping("/deleteOptionById/{id}")
    public void deleteOptionById(@PathVariable("id") Integer id) {
        System.out.println("删除岗位："+id);
        int i = positionService.deleteOptionById(id);
        System.out.println("删除结果："+i);
    }

    @PutMapping("/updateOption")
    public void updateOption(@RequestBody PositionReq positionReq) {
        positionService.updateOption(positionReq);
    }


}
